<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>0414-04 鼠标滚轮事件</title>
    <style>
        html, body {
            margin: 0;
            padding: 0;
            height: 100%;
            overflow: hidden;
        }

        .box {
            width: 3000px;
            height: 100%;
            background: linear-gradient(to right, black, yellow, red, yellow, blue, yellow, black);
        }
    </style>
</head>
<body>
<div class="box" id="box"></div>
<script src="../js/jquery-1.12.2.min.js"></script>
<script>
    var i = 0;
    var box = document.getElementById("box");
    var time = null;
    window.onmousewheel = function (e) {
        clearTimeout(time)
        time = setTimeout(function () {
            e.wheelDelta > 0 ? i-- : i++;
            i = i > 0 ? 0 : i;
            i = i < -130 ? -130 : i;
            box.style.transform = "translate(" + 1200 * i + "px)";
            console.log(1)
        },100)
    }
</script>
</body>
</html>













